import Vue from 'vue';
import Vuex from 'vuex';
Vue.use(Vuex);
 
const store = new Vuex.Store({
 
  state: {
    // 存储token
   // username,
    Authorization: localStorage.getItem('Authorization') ? localStorage.getItem('Authorization') : '',
    username: '',
    Auth: localStorage.getItem('Auth') ? localStorage.getItem('Auth') : '',
  },
 
  mutations: {
    // 修改token，并将token存入localStorage
    changeLogin (state,user) {
      console.log(state);
      console.log(user);
     // state.username=user.username;
      state.Authorization = user.Authorization;
      state.username=user.username;
      state.Auth=user.Auth;
      localStorage.setItem('Authorization', user.Authorization);
      localStorage.setItem('username', user.username);
      localStorage.setItem('Auth', user.Auth);
    }
  }
});
 
export default store;